<template>
  <div class="log other_common">
    <table class="common cent" id="logList">
      <thead>
        <tr>
          <th style="width:7%">编号</th>
          <th>类型</th>
          <th>操作位置</th>
          <th>操作前内容</th>
          <th>操作后内容</th>
          <th>操作时间</th>
        </tr>
      </thead>
      <tbody>
        <tr v-for="(item, index) in logList.data" :key="index">
          <td style="vertical-align: middle">{{ (index + 1) * curPage }}</td>
          <td style="vertical-align: middle">{{ item.type }}</td>
          <td style="vertical-align: middle">{{ item.location }}</td>
          <td>
            <textarea
              type="text/plain"
              style="height:60px;width:98%"
              readonly
              v-model="item.before_content"
            ></textarea>
          </td>
          <td>
            <textarea
              type="text/plain"
              style="height:60px;width:98%"
              readonly
              v-model="item.after_content"
            ></textarea>
          </td>
          <td style="vertical-align: middle">{{ item.create_time }}</td>
        </tr>
      </tbody>
    </table>
    <div id="model1Pages">
      <el-pagination
        prev-text="上一页"
        next-text="下一页"
        @current-change="currChange"
        layout="prev, pager, next"
        :current-page.sync="curPage"
        :page-size="pagesize"
        :total="logList.total"
        background
        hide-on-single-page
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { mapState, mapActions } from "vuex";
import http from "@/utils/http";
export default {
  data() {
    return {
      curPage: 1,
      pagesize: 10
    };
  },
  computed: {
    ...mapState("log", ["logList"])
  },
  methods: {
    ...mapActions("log", ["getLogList"]),
    currChange(val) {
      console.log(`当前页:${val}`);
      this.curPage = val;
      this.getLogList(val);
    }
  },
  created() {
    this.getLogList(1);
  }
};
</script>

<style>
.log {
  padding-top: 10px;
}
.log table .cent tr th,
td {
  text-align: center;
}
#model1Pages {
  text-align: center;
}
input[disabled],
select[disabled],
textarea[disabled],
input[readonly],
select[readonly],
textarea[readonly] {
  cursor: not-allowed;
  background-color: #eee;
}
</style>
